package com.wu.project.admin.api;

import com.wu.project.admin.annotations.Authorization;
import com.wu.project.admin.annotations.Log;
import com.wu.project.admin.component.JsonResult;
import com.wu.project.admin.entity.TicketDTO;
import com.wu.project.admin.entity.TicketQueryVO;
import com.wu.project.admin.entity.TicketRecordQueryVO;
import com.wu.project.admin.property.Constants;
import com.wu.project.admin.service.TicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xuan
 */
@RestController
@RequestMapping("/operator")
public class OperatorApi {

    @Autowired
    TicketService ticketService;

    @Authorization
    @Log(name = "获取卡券列表")
    @PostMapping(value = "/ticket", produces = Constants.APPLICATION_JSON_UTF8)
    public JsonResult ticket(@RequestBody TicketQueryVO ticketQueryVO){
        return ticketService.getTicketList(ticketQueryVO);
    }

    @Authorization
    @Log(name = "更新卡券信息")
    @PostMapping(value = "/updateTicket", produces = Constants.APPLICATION_JSON_UTF8)
    public JsonResult updateTicket(@RequestBody TicketDTO ticketDTO){
        return ticketService.updateTicket(ticketDTO);
    }

    @Authorization
    @Log(name = "增加卡券")
    @PostMapping(value = "/addTicket", produces = Constants.APPLICATION_JSON_UTF8)
    public JsonResult addTicket(@RequestBody TicketDTO ticketDTO){
        return ticketService.addTicket(ticketDTO);
    }

    @Authorization
    @Log(name = "查询发券发放记录")
    @PostMapping(value = "/ticketRecord", produces = Constants.APPLICATION_JSON_UTF8)
    public JsonResult record(@RequestBody TicketRecordQueryVO recordQueryVO){
        return ticketService.ticketRecord(recordQueryVO);
    }
}
